﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Model
{
    public class ImageResourceService
    {
        public ServiceResult<ImageResource> Save(ImageResource image)
        {
            using (JzSportDbContext dbContext = new JzSportDbContext())
            {
                ImageResourceRepository reps = new ImageResourceRepository(dbContext);

                reps.Save(image);

                if (dbContext.SaveChanges() > 0)
                {
                    return new ServiceResult<ImageResource>(ErrorCode.NoError, image);
                }
                return new ServiceResult<ImageResource>(ErrorCode.DB_Error);
            }
        }
    }
}
